use strict;
use utf8;

binmode(STDIN, ":encoding(utf-8)");
binmode(STDOUT, ":encoding(utf-8)");

while (<STDIN>) {
  if ($_ =~ /^INSERT INTO/) {
    while ($_ =~ /\((\d+),\'([^\']+)\',\'([^\']*)\',\'([^\']*)\',\'([^\']*)\',\'([^\']*)\',\'([^\']*)\'\)/g) {
      my ($from, $to, $sortkey, $timestamp, $sortkey_prefix, $collation, $type) = ($1, $2, $3, $4, $5, $6, $7);
      $to =~ s/\\\"/\"/g;
#      if ("subcat" eq $type) {
#        $to = "Категория:" . $to;
#      }
      print join("\t", ($from, $to, $sortkey, $timestamp, $sortkey_prefix, $collation, $type, "\n"));
    }
  }
}
